﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmXemDSPhieuNhap : Form
    {
        public frmXemDSPhieuNhap()
        {
            InitializeComponent();
        }

        private void frmXemDSPhieuNhap_Load(object sender, EventArgs e)
        {
            dgvDSPhieuNhap.Rows.Clear();
            LayDanhSachPNH();
            dgvChiTiet.Rows.Clear();
            LayDanhSachChiTietPNH();
        }
        private void LayDanhSachPNH()
        {
            int stt = dgvDSPhieuNhap.Rows.Count;
            PhieuNhapHangBUS pnhBUS = new PhieuNhapHangBUS();
            List<PhieuNhapHangDTO> listPNH = pnhBUS.LayDanhSachPNH();
            for (int i = 0; i < listPNH.Count; i++)
            {
                stt += 1;
                dgvDSPhieuNhap.Rows.Add(stt, listPNH[i].MaPhieuNhap, listPNH[i].MaNhaCungCap, listPNH[i].NgayNhap, listPNH[i].ThanhToan, listPNH[i].TongTien, listPNH[i].ConNo);
            }
        }

        private void LayDanhSachChiTietPNH()
        {
            int stt = dgvChiTiet.Rows.Count;
            ChiTietPhieuNhapHangBUS ctpnhBUS = new ChiTietPhieuNhapHangBUS();
            List<ChiTietPhieuNhapHangDTO> listCTPNH = ctpnhBUS.DanhSachChiTietPNH();
            for (int i = 0; i < listCTPNH.Count; i++)
            {
                stt += 1;
                dgvChiTiet.Rows.Add(stt, listCTPNH[i].MaCTPhieuNhap, listCTPNH[i].MaPhieuNhap, listCTPNH[i].MaMatHang, listCTPNH[i].MaXuatXu, listCTPNH[i].MaDonViTinh, listCTPNH[i].SoLuong, listCTPNH[i].GiaNhap);
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }

    }
}
